﻿using System;

namespace PusherClient
{
    internal class PusherChannelException : ApplicationException
    {
        private int _code;
        public int Code
        {
            get { return _code; }
            private set { _code = value; }
        }

        public PusherChannelException(PusherError error)
            : base(string.Format("{0}: {1}", error.Code, error.Message))
        {
            this.Code = error.Code;
        }

        public PusherChannelException(Exception ex) : base(ex.Message)
        {
            if (ex.Message != null && ex.Message.Contains(":"))
                int.TryParse(ex.Message.Split(':')[0], out this._code);
        }
    }
}